import java.util.Scanner;

/**
 * 求两个不大于100的整数的最小公倍数
 */

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int num1;
        int num2;
        num1 = scanner.nextInt();
        num2 = scanner.nextInt();
        while(true){
            num1 = (num1<num2?num2:num1);
            if(num1%num2==0){
                break;
            }
            num2 = num1-num2;
        }
    }
}